import java.util.Scanner;

public class maxyueShu {
    //最大公约数 * 最小公倍数 = a * b
    public static int lcmMath(int a, int b)
    {
        if(a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        int c ;
        while((a % b) != 0)
        {
            c = a % b;
            a = b;
            b = c;
        }
        return b;
    }
    //递归调用
    public static int lcmDigui(int a, int b)
    {
        //判断语句为最后一次递归的判断条件
        if(b == 0)
            return a;
        else
            return lcmDigui(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入a和b的值：");
        System.out.print("a = ");
        int a = sc.nextInt();
        System.out.print("b = ");
        int b = sc.nextInt();
        System.out.print("a和b的最大公因子是:");
        //System.out.println(lcmMath(a,b));
        System.out.println(lcmDigui(a,b));

    }
}

